#include <bits/stdc++.h>
#include "graph.h"
using namespace std;
const int N = 205;
int ans[N], vis[N], cnt, ds[N];
vector <int> to[N];
queue <int> q;
void dfs(int& x, int fa) {
    int bck = LastRoad();
    if(Color() == 1)
        x=++cnt;
    else {
        x=Color();
        Move(bck, Color());
        return ;
    }
    ds[x] =  NumberOfRoads();
    to[x].resize(ds[x]+5);
    for(int i = 1; i <= ds[x]; ++i) {
        Move(i, x);
        dfs(to[x][i], x);
    }
    if(bck != -1) 
        Move(bck, x);
}
void bfs(int x) {
    vis[x]=1;
    q.push(x);
    while(!q.empty()) {
        int now = q.front(); q.pop();
        for(int i = 1; i <= ds[now]; ++i)
            if(vis[to[now][i]] == 0) {
                vis[to[now][i]]=vis[now]+1;
                q.push(to[now][i]);
            }
    }
    for(int i = 2; i <= cnt; ++i)
        ++ans[vis[i]-1];
}
void Inspect(int R) {
    int rt = 0;
    cnt=1;
    dfs(rt, 0);
    for(int i = 2; i <= cnt; ++i)
        bfs(i);
    // for(int i = 1; i <= cnt; ++i)
    //     cerr<<ans[i]<<"????\n";
    // cerr<<cnt<<"???\n";
    for(int i = 1; i <= R; ++i)
        Answer(i, ans[i]);
}
